<template>
  <div>
    <!-- 头部图像 -->
    <div class="xiangqing-title">
      <div>
        <span @click="fun()"> &lt; </span>
      <span>{{newarr[0].title}}</span>
      </div>
      
      <img :src="newarr[0].img" alt="">
    </div>

<!-- 中间内容区 -->
<div class="xiangcon">
    <div class="xiangcon-top">

      <div class="xiangcon-topimg">
          <img :src="newarr[0].img" alt="">
      </div>
      


      <span class="xiangcon-topspan">{{newarr[0].con2}}> </span>
      <p>{{newarr[0].con1}}</p>
    </div>
   
    <h4>键盘预览</h4>

    <div v-for="(v,i) in newarrcon" :key="i" class="xiangqing-con">
      <p>{{v.con1}}</p>
      <p>{{v.con2}}</p>
      <p>{{v.con3}}</p>
      <p>{{v.con4}}</p>
      <p>{{v.con5}}</p>
      <p>{{v.con6}}</p>
      <p>{{v.con4}}</p>
      <p>{{v.con5}}</p>
      <p>{{v.con6}}</p>
      <p>{{v.con4}}</p>
      <p>{{v.con5}}</p>
      <p>{{v.con6}}</p>
      <p>{{v.con4}}</p>
      <p>{{v.con5}}</p>
      <p>{{v.con6}}</p>
    </div>
</div>


    <footer>
      <button @click="showShare = true">分享</button>
     <van-share-sheet
  v-model="showShare"
  title="立即分享给好友"
  :options="options"
/>
      <button>添加到键盘</button>
    </footer>




  </div>
</template>

<script>
import { Toast } from 'vant';
export default {
  data(){
    return{
      arr:[],
      newarr:[],
      arrcon:[],
      newarrcon:[],

// 点击分享的东西
      showShare: false,
      options: [
        [
          { name: '微信', icon: 'wechat' },
          { name: '微博', icon: 'weibo' },
          { name: 'QQ', icon: 'qq' },
        ],
        [
          { name: '复制链接', icon: 'link' },
          { name: '分享海报', icon: 'poster' },
          { name: '二维码', icon: 'qrcode' },
          { name: '小程序码', icon: 'weapp-qrcode' },
        ],
      ],
    }
  },
  created(){
    console.log(this.$route.params.id)
    // 上半部分数据
    this.arr=this.$store.state.shandetails.arrdetails
    console.log(this.arr)
    this.newarr = this.arr.filter((v)=>{
      if(v.id==this.$route.params.id){
        return v
      }
    })
    console.log(this.newarr)

     // 下半部分数据
    this.arrcon=this.$store.state.shandetails.arrdetails2
    console.log(this.arrcon)

    this.newarrcon = this.arrcon.filter((v)=>{
      if(v.id == this.$route.params.id){
        return v
      }
    })
  },
  methods:{
    fun(){
      this.$router.go(-1)
    },
    // 点击分享的东西
    onSelect(option) {
      Toast(option.name);
      this.showShare = false;
    },
  }
}
</script>

<style scoped>
/* 头部 */
  .xiangqing-title{
    width: 100%;
    height: 1.5rem;
    
  }
  
  .xiangqing-title div{
    width: 100%;
    height: 0.5rem;
    position: absolute;
    background-color: rgba(0, 0, 0,0.1);
    line-height: 0.5rem;
  }
  .xiangqing-title img{
    width: 100%;
    height: 1.6rem;
    
  }
  .xiangqing-title span{
    position: absolute;
    font-size: 0.2rem;
   
  }
  .xiangqing-title span:nth-of-type(1){
    color: white;
  }
  .xiangqing-title span:nth-of-type(2){
    color: white;
    left: 50%;
    transform: translateX(-50%);
  }

  /* 中间内容 */
  .xiangcon{
    width: 100%;
    height: auto;
    background-color: white;
    border-radius: 0.1rem 0.1rem 0 0;
    position: sticky;
    top: 0;
    z-index:1;
    box-sizing: border-box;
   padding: 0.2rem;
  }

  .xiangcon-top{
    height: 1.25rem;
    border-bottom: 0.01rem solid rgb(235, 233, 233);
     
  }
  .xiangcon-topimg{
    width: 0.48rem;
    height: 0.48rem;
    overflow: hidden;
    border-radius: 50%;
  }
  .xiangcon-top img{
    width: 0.48rem;
    height: 0.48rem;
  }
  .xiangcon-topspan{
    font-weight: bold;
    color: black;
    display: inline-block;
    position: absolute;
    top: 0.3rem;
    left: 0.8rem;
  }
  .xiangcon-top p{
    margin-top: 0.2rem;
  }

  .xiangcon h4{
    margin-top: 0.1rem;
    margin-bottom: 0.1rem;
  }
  .xiangqing-con p{
    width: 95%;
    height:auto;
    border-bottom: 0.01rem solid rgb(219, 219, 219);
    padding: 0.1rem 0;
  }

  /* 底部 */
  footer{
    width: 100%;
    height: 0.4rem;
    background-color: white;
    position: fixed;
    bottom: 0;
    z-index: 22;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
  }
  footer button:nth-of-type(1){
    width: 1.2rem;
    height: 0.3rem;
    background-color: white;
    border-radius: 0.2rem;
    outline: none;
    border: 0.01rem solid orangered;
    color: orangered;
  }
  footer button:nth-of-type(2){
    width: 2rem;
    height: 0.3rem;
    background-color: orangered;
    border-radius:  0.2rem;
    outline: none;
    border: 0.01rem solid orangered;
    color: white;
  }
</style>